/*
 * @Description: 
 * @Version: 2.0
 * @Autor: ftt
 * @Date: 2022-06-13 11:10:41
 * @LastEditors: TT
 * @LastEditTime: 2022-06-22 16:04:27
 */

import 'package:flutter/material.dart';
import 'package:hzy_normal_widget/hzy_getx_utils.dart';
import 'package:ttcomment/ttcomment.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import '../../../components/common_widgets.dart';
import '../../../config/config_index.dart';
import '../../../config/dataconfig/font_config.dart';

class LoginNormalPage extends TTNormalStatefulWidget {
  /// 界面子视图
  final List<Widget> loginchild;

  /// 其他界面
  final Widget? otherwidget;
  const LoginNormalPage({
    Key? key,
    required this.loginchild,
    this.otherwidget,
  }) : super(key: key);

  @override
  TTNormalState<TTNormalStatefulWidget> getState() {
    return _LoginNormalPageState();
  }
}

class _LoginNormalPageState extends TTNormalState<LoginNormalPage> {
  /// 属性
  ///
  ///

  @override
  bool get safeAreabottm => false;
  @override
  bool get safeAreatop => false;
  @override
  bool get resizeToAvoidBottomInset => false;

  /// 生命周期
  ///
  ///

  /// 界面初始化
  @override
  void initDefaultState() {
    super.initDefaultState();
  }

  /// 界面销毁
  @override
  void initDefaultDispose() {
    super.initDefaultDispose();
  }

  /// 网路请求
  ///
  ///

  /// 构建视图
  ///
  ///

  @override
  Widget createBody(BuildContext context) {
    return configNoramalBgWidget();
  }

  Widget configNoramalBgWidget() {
    return Container(
      decoration: BoxDecoration(
        color: HzyColorConfig().colefedf3,
      ),
      height: SizeMacro.screenHeight,
      width: SizeMacro.screenWidth,
      child: Stack(
        children: configNormalBg(),
      ),
    );
  }

  List<Widget> configNormalBg() {
    List<Widget> list = [];
    list.add(createclosebtn());
    list.add(createloginbgWidget());
    if (widget.otherwidget != null) {
      list.add(widget.otherwidget!);
    }
    return list;
  }

  // 创建关闭按钮
  Widget createclosebtn() {
    return AppBarGenerator.isfirstPage(context: context)
        ? Positioned(
            right: 20.w,
            top: SizeMacro.statusBarHeight,
            width: 44.w,
            height: 44.w,
            child: IconButton(
              onPressed: () {
                currentGoback(context);
              },
              icon: const Icon(
                Icons.close,
              ),
            ),
          )
        : Container();
  }

  Widget createloginbgWidget() {
    double toph = SizeMacro.statusBarHeight + 44 + 20;
    List<Widget> list = [];
    list.add(
      Text(
        "撕裂面具  重启人生",
        style: FontConfig().fontBold26Block,
      ),
    );
    list.addAll(widget.loginchild);
    return Positioned(
      left: 20,
      right: 20,
      top: toph,
      bottom: toph,
      child: Container(
        padding: EdgeInsets.only(
          top: 40.w,
          left: 20.w,
          right: 20.w,
        ),
        decoration: BoxDecoration(
          boxShadow: [
            configShadow(),
          ],
          color: HzyColorConfig().whitebackgroundColor,
          borderRadius: BorderRadius.all(
            Radius.circular(
              20.r,
            ),
          ),
        ),
        child: Column(
          children: list,
        ),
      ),
    );
  }

  /// 触发方法
  ///
  ///

  /// 配置默认数据
  @override
  void configNormalData() {}
}
